<template>
	<view class="wrap">
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">物种详情信息</block>
		</cu-custom>

		<view class="mian" v-model="item">
			<view class="demo-warter w-50 ">
				<view class="demo-title">
					{{item.specyName}}
				</view>
				<view class="demo-tag">
					<view class="demo-tag-owner">
						{{item.specyFamily}}
					</view>
					<view class="demo-tag-text">
						{{item.specyGenus}}
					</view>
				</view>
				<view class="spe_img">
					<image v-if="item.specyImage" :src="baseUrl+item.specyImage" mode=""></image>
					<image v-if="!item.specyImage" :src="imagedf" mode=""></image>
				</view>
				<view class="dtile">
					<view class="rit">
						<view class="demo-text">
							拉丁学名:{{item.latinName}}
						</view>
						<view class="demo-text">
							别称:{{item.anotherName}}
						</view>
						<view class="demo-text">
							界:{{item.plantKingdom}}
						</view>
						<view class="demo-text">
							门:{{item.plantPhylum}}
						</view>
						<view class="demo-text">
							纲:{{item.plantClass}}
						</view>
						<view class="demo-text">
							亚纲:{{item.plantSuborder}}
						</view>
						<view class="demo-text">
							目:{{item.plantOrder}}
						</view>
						<view class="demo-text">
							亚目:{{item.plantOrder}}
						</view>
						<view class="demo-text">
							科名:{{item.specyFamily}}
						</view>
						<view class="demo-text">
							属名:{{item.specyGenus}}
						</view>
						<view class="demo-text">
							原产地:{{item.sourceArea}}
						</view>
						<view class="demo-text">
							风险管理:{{item.plantRisk}}
						</view>
						<view class="demo-text">
							危险等级:{{item.detailType}}
						</view>
					</view>
				</view>
				<view class="foot">
					<view class="demo-text">
						最早记载(中国境内):
					</view>
					<view class="demo-text-sm">
						{{item.plantEarliest}}
					</view>
					<view class="demo-text">
						分布信息:
					</view>
					<view class="demo-text-sm">
						{{item.plantDistriction}}
					</view>
					<view class="demo-text">
						生境偏好:
					</view>
					<view class="demo-text-sm">
						{{item.plantEnvironment}}
					</view>
					<view class="demo-text">
						生物特征:
					</view>
					<view class="demo-text-sm">
						{{item.plantCharacter}}
					</view>
					<view class="demo-text">
						主要用途:
					</view>
					<view class="demo-text-sm">
						{{item.plantUsage}}
					</view>
					<view class="demo-text">
						主要危害:
					</view>
					<view class="demo-text-sm">
						{{item.plantHarm}}
					</view>
					<view class="demo-text">
						备注:
					</view>
					<view class="demo-text-sm">
						{{item.remark}}
					</view>
					<view class="demo-text">
						叶图片:
					</view>
					<view class="demo-text-sm">
						<image v-for="img in item.plantLeaf" :key="img+'-only'" :src="img" :alt="img" />
					</view>
					<view class="demo-text">
						花图片:
					</view>
					<view class="demo-text-sm">
						<image v-for="img in item.plantFlower" :key="img+'-only'" :src="img" :alt="img" />
					</view>
					<view class="demo-text">
						果实图片:
					</view>
					<view class="demo-text-sm">
						<image v-for="img in item.plantFruitgains" :key="img+'-only'" :src="img" :alt="img" />
					</view>
					<view class="demo-text">
						根图片:
					</view>
					<view class="demo-text-sm">
						<image v-for="img in item.plantRoot" :key="img+'-only'" :src="img" :alt="img" />
					</view>
				</view>




				<!-- <u-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.id)"></u-icon> -->
			</view>
		</view>
	</view>



</template>

<script>
	import proData from "@/common/projectData.js";
	import imgData from "@/common/uiImg.js";
	import {baseUrl} from '../../common/utils/request.js'
	import {
		getAnimalInfo,
		getAnimalDtil,
		getPlantInfo,
		getPlantDtil,
		getMicrobeInfo,
		getMicrobeIDtil,
		selectDictLabel
	} from '../../common/api/info.js'
	import {
		checkNullAndUndefine
	} from '../../common/utils/checkNU.js'
	export default {
		data() {
			return {
				baseUrl:'',
				item: {},
				imagedf: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1274304873,2136522871&fm=26&gp=0.jpg',
				queryParams: {},
				detailType:[
					{value: 0,label:'未知'},
					{value: 1,label:'恶性入侵植物'},
					{value: 2,label:'严重入侵植物'},
					{value: 3,label:'局部入侵植物'},
					{value: 4,label:'一般入侵植物'},
					{value: 5,label:'有待观察植物'},
					{value: 6,label:'建议排除植物'},
					{value: 7,label:'中国原产植物'}
				]
			}
		},
		onLoad(option) {
			this.baseUrl = baseUrl
			console.log(option.specyId)
			// this.type = option.type;
			this.addRandomData(option.specyId);
		},
		// onReachBottom() {
		// 	this.loadStatus = 'loading';
		// 	// 模拟数据加载
		// 	setTimeout(() => {
		// 		this.addRandomData();
		// 		this.loadStatus = 'loadmore';
		// 	}, 1000)
		// },
		methods: {
			addRandomData(specyId) {
				getPlantDtil(specyId).then(response => {
					this.item = response[1].data.data;
					this.item.detailType = selectDictLabel(this.detailType, this.item.detailType);
					if (this.item.plantFruitgains != null && this.item.plantFruitgains != "") {
						this.item.plantFruitgains = this.item.plantFruitgains
							.split(",")
							.map(a => {
								return this.baseUrl + a;
							});
					}
					
					if (this.item.plantFlower != null && this.item.plantFlower != "") {
						this.item.plantFlower = this.item.plantFlower
							.split(",")
							.map(a => {
								return this.baseUrl + a;
							});
					}
					
					if (this.item.plantLeaf != null && this.item.plantLeaf != "") {
						this.item.plantLeaf = this.item.plantLeaf
							.split(",")
							.map(a => {
								return this.baseUrl + a;
							});
					}
					
					if (this.item.plantRoot != null && this.item.plantRoot != "") {
						this.item.plantRoot = this.item.plantRoot
							.split(",")
							.map(a => {
								return this.baseUrl + a;
							});
					}
					
					for (let i in this.item) {
						if (i!='specyImage'&&i != 'plantFruitgains'&&i!='plantFlower'&&i!='plantLeaf'&&i!='plantRoot') {
							this.item[i] = checkNullAndUndefine(this.item[i])
						}
					}
					
				});

				
				 console.log(this.item);
			}
		}
	}
</script>

<style>
	/* page不能写带scope的style标签中，否则无效 */
	page {
		background-color: rgb(240, 240, 240);
	}
</style>

<style lang="scss" scoped>
	.demo-image {
		width: 100%;
		border-radius: 4px;
	}

	.demo-title {
		font-size: 45rpx;
		margin-top: 5px;
		color: $u-main-color;
	}

	.demo-tag {
		display: flex;
		margin-top: 15rpx;
		margin-bottom: 15rpx;
	}

	.demo-tag-owner {
		background-color: $u-type-success;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		padding: 4rpx 14rpx;
		border-radius: 50rpx;
		font-size: 20rpx;
		line-height: 1;
	}

	.demo-tag-text {
		border: 1px solid $u-type-success;
		color: $u-type-success;
		margin-left: 10px;
		border-radius: 50rpx;
		line-height: 1;
		padding: 4rpx 14rpx;
		display: flex;
		align-items: center;
		border-radius: 50rpx;
		font-size: 20rpx;
	}

	.demo-text-sm {
		margin: 10px;
		line-height: 2;
	}

	.demo-text {
		margin: 10px;
		line-height: 2;
		font-weight: 700;
	}

	.demo-shop {
		font-size: 22rpx;
		color: $u-tips-color;
		margin-top: 5px;
	}

	.mian {
		width: 257%;
	}

	.w-50 {
		width: 38%;
	}

	.demo-warter {
		border-radius: 8px;
		margin: 10px 5px;
		background-color: #ffffff;
		padding: 8px;
		position: relative;
	}

	.dtile {
		display: flex;
		flex-wrap: wrap;
	}

	.rit {
		margin-left: 5px;
	}

	.foot {
		margin-left: 5px;
	}

	.spe_img {
		margin: 10px;
	}
</style>
